Skip to content

bugfix: do not panic if a sketch profile has a syntax error #2506

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 18, 2024

Conversation

cmaglie
Copy link
Member

@cmaglie cmaglie commented Jan 18, 2024

Please check if the PR fulfills these requirements

See how to contribute

  • The PR has no duplicates (please search among the Pull Requests
    before creating one)
  • The PR follows
    our contributing guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • UPGRADING.md has been updated with a migration guide (for breaking changes)
  • configuration.schema.json updated if new parameters are added.

What kind of change does this PR introduce?

Do not panic if a sketch profile has a syntax error.

What is the current behavior?

~/Arduino/Blink$ cat sketch.yaml 
profiles:
  uno:
    fqbn: arduino:avr:uno
    platforms:
      - platform: arduino:avr (aaaa1.8.6)

~/Arduino/Blink$ arduino-cli compile --profile uno 
panic: profiles parsing err: si è verificato un errore durante il parsing dei vincoli di versione: no major version found

goroutine 1 [running]:
github.com/arduino/arduino-cli/internal/arduino/sketch.(*projectRaw).getProfiles(0xc000500000)
	/home/megabug/Workspace/arduino-cli/internal/arduino/sketch/profiles.go:85 +0x1fe
github.com/arduino/arduino-cli/internal/arduino/sketch.LoadProjectFile(0xc00034a620?)
	/home/megabug/Workspace/arduino-cli/internal/arduino/sketch/profiles.go:274 +0xb6
github.com/arduino/arduino-cli/internal/arduino/sketch.New(0xc000275608?)
	/home/megabug/Workspace/arduino-cli/internal/arduino/sketch/sketch.go:93 +0x5de
github.com/arduino/arduino-cli/commands/sketch.LoadSketch({0x0?, 0x4?}, 0xc000275930?)
	/home/megabug/Workspace/arduino-cli/commands/sketch/load.go:29 +0x4d
github.com/arduino/arduino-cli/internal/cli/compile.runCompileCommand(0xc000445800?, {0xc0004425a0, 0x0, 0xf1664a?})
	/home/megabug/Workspace/arduino-cli/internal/cli/compile/compile.go:162 +0x1dc
github.com/spf13/cobra.(*Command).execute(0xc000445800, {0xc000442580, 0x2, 0x2})
	/home/megabug/Software/go/pkg/mod/github.com/spf13/[email protected]/command.go:987 +0xaa3
github.com/spf13/cobra.(*Command).ExecuteC(0xc000137b00)
	/home/megabug/Software/go/pkg/mod/github.com/spf13/[email protected]/command.go:1115 +0x3ff
github.com/spf13/cobra.(*Command).Execute(0x0?)
	/home/megabug/Software/go/pkg/mod/github.com/spf13/[email protected]/command.go:1039 +0x13
main.main()
	/home/megabug/Workspace/arduino-cli/main.go:31 +0x74

What is the new behavior?

:~/Arduino/Blink$ arduino-cli compile --profile uno 
Can't open sketch: error loading sketch project file: error parsing version constraints: no major version found

Does this PR introduce a breaking change, and is titled accordingly?

No

Other information

@cmaglie cmaglie added type: enhancement Proposed improvement topic: code Related to content of the project itself labels Jan 18, 2024
@cmaglie cmaglie self-assigned this Jan 18, 2024
Copy link
Contributor

@alessio-perugini alessio-perugini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sweet

Copy link

codecov bot commented Jan 18, 2024

Codecov Report

Attention: 4 lines in your changes are missing coverage. Please review.

Comparison is base (3ccdb9d) 68.92% compared to head (09dd8fc) 68.92%.

Files Patch % Lines
internal/arduino/sketch/profiles.go 50.00% 3 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2506      +/-   ##
==========================================
- Coverage   68.92%   68.92%   -0.01%     
==========================================
  Files         204      204              
  Lines       20451    20452       +1     
==========================================
  Hits        14096    14096              
- Misses       5206     5207       +1     
  Partials     1149     1149              
Flag Coverage Δ
unit 68.92% <50.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@cmaglie cmaglie merged commit 96b411f into arduino:master Jan 18, 2024
@cmaglie cmaglie deleted the fix_1 branch January 18, 2024 10:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: code Related to content of the project itself type: enhancement Proposed improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants